package controller;

import com.alibaba.fastjson2.JSON;
import entity.ResponseResult;
import entity.User;
import service.UserService;
import service.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/findUser")
public class findAllUser {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf-8");
        UserService st=new UserServiceImpl();
        List<User> users = st.findAllUsers();
        ResponseResult result = new ResponseResult(200,"查询成功",users);
        String str = JSON.toJSONString(result);
        resp.getWriter().write(str);
    }
}
